import  time

'''def test1(func):
    print(func)
    func()
def bar():
    print("in the bar")

test1(bar)'''

'''def test1(func):
    start_time=time.time()
    func()
    stop_time=time.time()
    print("the func run time is %s"%(stop_time-start_time))
def bar():
    time.sleep(10)
    print("in the bar")

test1(bar)'''

'''def bar():              #原函数
    time.sleep(2)
    print("--in the bar--")
def test2(func):
    time.sleep(2)
    print(func)
    return func
#print(test2(bar))

bar=test2(bar)
bar()'''


#test1()
#test2()


def timer(func):
    def deco():
        star_time=time.time()
        func()
        stop_time=time.time()
        print("the func time is %s"%(star_time-stop_time))
    return deco


@timer
def test1():
    time.sleep(3)
    print("in the test1")
@timer
def test2():
    time.sleep(3)
    print("in the test2")
#deco(test1)
#deco(test2)
#print(timer(test1))
#test1=timer(test1)
test1()
test2()